package jdk8;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class CollectTest {

    @Test
    public void test() {
        List<String> stringList = new ArrayList<>();
        stringList.add("aaa");
        stringList.add("bb");
        stringList.add("aaa");
        stringList.add("c");
        stringList.stream().mapToInt(String::length).summaryStatistics().getAverage();
        /*stringList.stream().mapToInt(String::length).summaryStatistics().getAverage();
        System.out.println(stringList.stream().reduce((a, b) -> a + b).get());
        System.out.println(stringList.stream().reduce("xxxx", (a, b) -> a + b));
        System.out.println(stringList.stream().collect(StaticString::new,
                (a, b) -> a.getStringBuilder().append(b),
                (a, b) -> b.getStringBuilder()).getStringBuilder().toString());
        System.out.println(stringList.parallelStream().collect(StaticString::new,
                (a, b) -> a.getStringBuilder().append(b),
                (a, b) -> a.getStringBuilder().append(b.getStringBuilder())).getStringBuilder().toString());*/
    }
}

/*
class StaticString {
    private StringBuilder stringBuilder = new StringBuilder();


    public StringBuilder getStringBuilder() {
        return stringBuilder;
    }

    public void setStringBuilder(StringBuilder stringBuilder) {
        this.stringBuilder = stringBuilder;
    }
}*/
